﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using YLPublicService.TransferModel;
using YLServerInterface.FunctionalClass;

namespace YLServerInterface.Forms
{
    /// <summary>
    /// 通过名称映射模板
    /// </summary>
    [ValueConversion(typeof(string), typeof(TemplateItem))]
    public class MapTemplateItem : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var mName = value as string;
            var item = from t in Caches.TemplateItems
                       where t.mTemplateDetial.mName == mName
                       select t;
            if (item.Count() > 0)
            {
                return item.First();
            }
            else return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
